package com.genexususa.eo.google.test.conversion;


import com.genexususa.eo.google.connection.ConversionTrackerManager;
import com.genexususa.eo.google.data.AdCallMetricsConversionReport;
import com.genexususa.eo.google.data.GA_Report;
import com.genexususa.eo.google.test.Constants;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;
import java.util.ArrayList;

public class ConsumeGetAdCallMetricsConversionReport {

    public static void main(String[] args){

        ConversionTrackerManager ctm = new ConversionTrackerManager();
        ctm.SetClientId(Constants.testAccountEmiliano);
        ArrayList<AdCallMetricsConversionReport> report = ctm.GetAdCallMetricsConversionReport(Constants.testAccountEmiliano);

        GA_Report rep = new GA_Report();
        rep.AdCallMetricsConversions = report;

        try {

            String result = "";
            JAXBContext contextObj = JAXBContext.newInstance(GA_Report.class);
            Marshaller marshallerObj = contextObj.createMarshaller();
            marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            StringWriter sw = new StringWriter();
            marshallerObj.marshal(rep, sw);
            result = sw.getBuffer().toString();
            System.out.println(result);

        } catch (Exception exc) {
            exc.printStackTrace();
        }

    }
}
